﻿using Axiom.Hermetica.WPF.Models;
using Neocortex.WPF.Hermetica;
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Runtime.Serialization.Formatters.Binary;
using System.Security.Cryptography;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Xml;

namespace Axiom.Hermetica.WPF.ViewModels
{
	public class MutiEditorViewModel : ViewModel
	{
		public MutiEditorViewModel(ViewModel _mainViewModel)
		{
			this._items = _mainViewModel.SelectedItems;			
		}

		public string Author
		{
			get
			{
				var item = Items.FirstOrDefault();
				if (item == null)
				{
					return string.Empty;
				}
				var value = item.Author;
				if (Items.All(a => a.Author == value))
				{
					return value;
				}
				return string.Empty;
			}
			set
			{
				Items.ToList().ForEach(a => a.Author = value);
				NotifyPropertyChanged("Author");
			}
		}
		public string Subject
		{
			get
			{
				var item = Items.FirstOrDefault();
				if (item == null)
				{
					return string.Empty;
				}
				var value = item.Subject;
				if (Items.All(a => a.Subject == value))
				{
					return value;
				}
				return string.Empty;
			}
			set
			{
				Items.ToList().ForEach(a => a.Subject = value);
				NotifyPropertyChanged("Subject");
			}
		}
		public string Category
		{
			get
			{
				var item = Items.FirstOrDefault();
				if (item == null)
				{
					return string.Empty;
				}
				var value = item.Category;
				if (Items.All(a => a.Category == value))
				{
					return value;
				}
				return string.Empty;
			}
			set
			{
				Items.ToList().ForEach(a => a.Category = value);
				NotifyPropertyChanged("Category");
			}
		}
		public string Keywords
		{
			get
			{
				var item = Items.FirstOrDefault();
				if (item == null)
				{
					return string.Empty;
				}
				var value = item.Keywords;
				if (Items.All(a => a.Keywords == value))
				{
					return value;
				}
				return string.Empty;
			}
			set
			{
				Items.ToList().ForEach(a => a.Keywords = value);
				NotifyPropertyChanged("Keywords");
			}
		}
	}
}
